<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<style>
			body { margin: 0; }
		</style>
		<script src="../utils/setTitle.js"></script>
	</head>
	<body>
		<script type="importmap">
			{
				"imports": {
					"three": "https://unpkg.com/three/build/three.module.js"
				}
			}
		</script>
		<script type="module">
			import * as THREE from 'three';
			const scene = new THREE.Scene();
			const camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 );
			
			class CustomSinCurve extends THREE.Curve {
				constructor( scale = 1 ) {
					super();
					this.scale = scale;
				}
				getPoint( t, optionalTarget = new THREE.Vector3() ) {
					const tx = t * 3 - 1.5;
					const ty = Math.sin( 2 * Math.PI * t );
					const tz = 0;
					return optionalTarget.set( tx, ty, tz ).multiplyScalar( this.scale );
				}
			}

			const path = new CustomSinCurve( 10 );
			const geometry = new THREE.TubeGeometry( path,15, 3, 4, false );
			const material = new THREE.MeshBasicMaterial( { color: 0x00ff00 } );
			const mesh = new THREE.Mesh( geometry, material );
			scene.add( mesh );
			camera.position.z = 55;
			const renderer = new THREE.WebGLRenderer();
			renderer.setSize( window.innerWidth, window.innerHeight );
			document.body.appendChild( renderer.domElement );
			function animate() {
				requestAnimationFrame( animate );
				mesh.rotation.x += 0.01;
				mesh.rotation.y += 0.01;
				renderer.setSize( window.innerWidth, window.innerHeight );
				renderer.render( scene, camera );
			}
			animate();
		</script>
	</body>
</html>